package com.baihan.angus.app.game.busshow.ui.script_library.genuine_store;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.baihan.angus.app.game.basic.base.view_model.BaseViewModel;
import com.baihan.angus.app.game.basic.utils.Tooast;
import com.baihan.angus.app.game.basic.utils.net.ApiObserver;
import com.baihan.angus.app.game.common.bean.response.StoreResponse;
import com.baihan.angus.app.game.common.data_center.remote.RemoteDataMng;

import java.util.Map;

public class StoreListVM extends BaseViewModel {

    public StoreListVM(@NonNull Application application) {
        super(application);
    }

    public MutableLiveData<StoreResponse.DataX> mldStore = new MutableLiveData<>();

    public void getStoreList(int role_id, Map<String, Object> pMap) {
        showLoading("getStoreList");
        RemoteDataMng.getInstance().getStoreList(role_id, pMap, mLifecycleProvider.bindToLifecycle(), new ApiObserver<StoreResponse>() {
            @Override
            public void onSuccess(StoreResponse storeResponse) {
                hideLoading("getStoreList");
                mldStore.setValue(storeResponse.getData());
            }

            @Override
            public void onFailed(int code, String msg) {
                hideLoading("getStoreList");
                Tooast.warning(msg);
                mldStore.setValue(null);
            }
        });
    }
}
